FeaturePortlet = Class.extend({
	init: function()	{
		this.name = "FeaturePortlet";
	},
	
	onBegin: function()	{
		this.model = {};
		this.registerObserver();
	},
	
	onEnd: function()	{
		this.unregisterObserver();
	},
	
	onShowProductTooltip: function(eventData)	{
		var product = this.currentProducts[eventData];
		var tooltip = this.renderView('Tooltip', product);
		showtip(tooltip);
	},

	run: function()	{
		var obj = this;
		this.onAjax('product', 'load-featured-products', {}, 'GET', {
			'onSuccess': function(ret)	{
				obj.model = {};
				obj.model.products = ret;
				for(var i=0;i<ret.length;i++) {
					ret[i].description = ret[i].description.substr(0, 100)+'...';
				}
				obj.currentProducts = ret;
				obj.getPortletPlaceholder().paintCanvas(obj.render());
			}
		});
	}
}).implement(PortletInterface).implement(RenderInterface).implement(AjaxInterface).implement(ObserverInterface);